<?php
/*========================================= JooSam =========================================/
/																							/
/	Extention:		JooSam																	/
/	Created by:		ScriptPlanet.eu															/
/	Site:			http://www.scriptplanet.eu												/
/	Email:			support@scriptplanet.eu													/
/	Support:		http://www.scriptplanet.eu/support										/
/	Copyright:		2011 (c) ScriptPlanet.eu												/
/	License:		CC BY-NC-ND 3.0 ~ http://creativecommons.org/licenses/by-nc-nd/3.0/		/
/	File Version:	0001																	/
/																							/
/========================================== JooSam ========================================*/
$obj = new jsamEvents();
$data = $obj->updateEvent();

if($data == 'code100'){
	$output = '
		<input type="hidden" id="jsamDayError" value="0" />
		<input type="hidden" id="jsamWeekError" value="0" />
		<input type="hidden" id="jsamDayDone" value="0" />
		<input type="hidden" id="jsamWeekDone" value="0" />';
}
else if($data == 'code101'){
	$output = '
		<input type="hidden" id="jsamDayError" value="0" />
		<input type="hidden" id="jsamWeekError" value="0" />
		<input type="hidden" id="jsamDayDone" value="0" />
		<input type="hidden" id="jsamWeekDone" value="0" />';
}
else if($data == ''){
	$output = '
		<input type="hidden" id="jsamDayError" value="0" />
		<input type="hidden" id="jsamWeekError" value="0" />
		<input type="hidden" id="jsamDayDone" value="0" />
		<input type="hidden" id="jsamWeekDone" value="0" />';
}
else{
	$dDone = 0;
	$dError = 0;
	$wDone = 0;
	$wError = 0;
	foreach($data as $event){
		$id = $event['id'];
		$type = $event['type'];
		$start_old = $event['start_old'];
		$start_new = $event['start_new'];
		$end_old = $event['end_old'];
		$end_new = $event['end_new'];
		$counter = $event['counter'];
		$update = $event['update'];

		if($type == 'daily' and $update == 1){
			$dDone = $dDone+1;
		}

		else if($type == 'daily' and $update == 2){
			$dError = $dError+1;
		}

		else if($type == 'weekly' and $update == 1){
			$wDone = $wDone+1;
		}

		else if($type == 'weekly' and $update == 2){
			$wError = $wError+1;
		}
	}
	$output = '
		<input type="hidden" id="jsamDayError" value="'.$dError.'" />
		<input type="hidden" id="jsamWeekError" value="'.$wError.'" />
		<input type="hidden" id="jsamDayDone" value="'.$dDone.'" />
		<input type="hidden" id="jsamWeekDone" value="'.$wDone.'" />';
}

echo $output;
?>